package com.gw.yunke.service.impl;

import com.gw.yunke.dao.PartVideoMapper;
import com.gw.yunke.domain.PartVideo;
import com.gw.yunke.domain.PartVideoExample;
import com.gw.yunke.service.IPartVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PartVideoServiceImpl implements IPartVideoService{

    @Autowired
    private PartVideoMapper partVideoMapper;

    //@Cacheable
    @Override
    public Long getVideoIdByPartId(Long partId) {
        PartVideoExample example = new PartVideoExample();
        PartVideoExample.Criteria criteria = example.createCriteria();
        criteria.andPartIdEqualTo(partId);
        List<PartVideo> partVideoList = partVideoMapper.selectByExample(example);
        if(partVideoList.size() > 0)
            return partVideoList.get(0).getVideoId();
        else
            return -1L;
    }

    @Override
    public int createPartVideo(PartVideo partVideo) {
        return partVideoMapper.insertSelective(partVideo);
    }
}
